#include<stdio.h>

int main() {
	int n = 0, m = 0;
	char a[100][100] = { 0 };
	scanf_s("%d %d", &n, &m);




	int i = 0, j = 0;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			scanf_s(" %c", &a[i][j]);
			if (a[i][j] == '?') {
				a[i][j] = 0;
			}
			else if (a[i][j] == '*') {
				a[i][j] = 1;
			}
		}
	}

	int cnt = 0;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			if (a[i][j] == 1) {
				printf("*");
			}
			else {
				cnt = a[i - 1][j - 1] + a[i][j - 1] + a[i - 1][j] + a[i + 1][j + 1] + a[i][j + 1] + a[i + 1][j] + a[i - 1][j + 1] + a[i + 1][j - 1];
				printf("%d", cnt);
			}
		}
		printf("\n");
	}
	return 0;
}
